﻿@model BaseballGame.ViewModel.standingsViewModel

@{
    ViewBag.Title = "Standings";
}

  
<fieldset>
    <legend>League Standings</legend>
<table>
@foreach (var standingFieldDisplay in Model.standings.OrderBy(t => t.games_Won))
{
    <tr>
        <td>
           
        </td>
        <td>
            @Html.DisplayNameFor(model => standingFieldDisplay.games_played)
        </td>
        <td>
            @Html.DisplayNameFor(model => standingFieldDisplay.games_Won)
        </td>
        <td>
            @Html.DisplayNameFor(model => standingFieldDisplay.games_lost)
        </td>
    </tr>
    break;
}

@foreach (var standing in Model.standings)
{
    <tr>
        <td>
            @if (standing.team.teamName == null)
            {
                @ViewBag.defteamname
            }
            else
            {
            @Html.DisplayFor(model => standing.team.teamName)
            }
        </td>
        <td>
            @Html.DisplayFor(model => standing.games_played)
        </td>
        <td>
            @Html.DisplayFor(model => standing.games_Won)
        </td>
        <td>
            @Html.DisplayFor(model => standing.games_lost)
        </td>
    </tr> 
}

</table>
</fieldset>

    @foreach (var latestgame in Model.gamestats)
{
    <fieldset>
        <legend> game </legend>    
    <table>  
    <tr>
        <td>
            @Html.ActionLink("Game Details", "GameDetails", new { id=latestgame.id }) 
        </td>
        <td>
            <h4>1</h4>
        </td>
        <td>
            <h4>2</h4>
        </td>
        <td>
            <h4>3</h4>
        </td>
        <td>
            <h4>4</h4>
        </td>
        <td>
            <h4>5</h4>
        </td>
        <td>
            <h4>6</h4>
        </td>
        <td>
            <h4>7</h4>
        </td>
        <td>
            <h4>8</h4>
        </td>
        <td>
            <h4>9</h4>
        </td>
        <td>
            <h4>R</h4>
        </td>
        <td>
            <h4>H</h4>
        </td>
        <td>
            <h4>HR</h4>
        </td>
        <td>
            <h4>E</h4>
        </td>
    </tr>
        <tr>
           <td><b>@Html.DisplayFor(model => latestgame.HomeScore):@Html.DisplayFor(model => latestgame.AwayScore)</b></td>
        </tr>
    <tr>
        <td>
           @foreach ( var teamA in Model.standings.Where(t => t.teamId == latestgame.HomeTeamID))
            {
                if (teamA.team.teamName == null)
                {
                   @ViewBag.defteamname
                }
                else
                {
                    @Html.DisplayFor(model => teamA.team.teamName)
                }
            }
            
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn1)
        </td>
       <td>
            @Html.DisplayFor(model => latestgame.topIn2)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn3)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn4)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn5)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn6)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn7)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn8)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topIn9)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.HomeScore)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.homeHits)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.homeHR)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.topInE)
        </td>
    </tr> 
    <tr>
        <td>
        @foreach ( var teamB in Model.standings.Where(t => t.teamId == latestgame.AwayTeamID))
            {
                if (teamB.team.teamName == null)
                {
                   @ViewBag.defteamname
                }
                else{                  
                        @Html.DisplayFor(model => teamB.team.teamName)
                    }
            }
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn1)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn2)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn3)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn4)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn5)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn6)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn7)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn8)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botIn9)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.AwayScore)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.awayHits)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.awayHR)
        </td>
        <td>
            @Html.DisplayFor(model => latestgame.botInE)
        </td>
    </tr>
    </table>
</fieldset>
}




<p>
    @Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) |
    @Html.ActionLink("Back to List", "Index")
</p>
